"""
pip install selenium
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Edge()  # 启用edge浏览器

driver.get("https://www.selenium.dev/selenium/web/web-form.html")  # 控制浏览器进入该网络

driver.implicitly_wait(0.5)  # 设置等待再执行（进入浏览器之后，再等待0.5s，然后获取title）

title = driver.title  # 上述网页的titile的内容
print(title)

text_box = driver.find_element(by=By.NAME, value="my-text")  # <input name="my-text"></input>
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")  # <button>提交按钮</button>

text_box.send_keys("Selenium")  # 往当前的输入input中写入"Selenium"
submit_button.click()  # 点击当前的提交按钮

message = driver.find_element(by=By.ID, value="message")  # <div id="message">admin</div>
text = message.text  # 此处就为获取上述div中admin内容

driver.quit()  # 退出浏览器
